package com.yami.shop.nftaccount.common.listener;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.yami.shop.bean.event.AssetTrendsEvent;
import com.yami.shop.bean.vo.AssetTrendsVO;
import com.yami.shop.nftaccount.common.model.NftAssetTrends;
import com.yami.shop.nftaccount.common.service.NftAssetTrendsService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component("assetListener")
@AllArgsConstructor
public class AssetListener {

    private final NftAssetTrendsService assetTrendsService;

    @EventListener(AssetTrendsEvent.class)
    public void saveAssetTrendsList(AssetTrendsEvent event) {
        List<AssetTrendsVO> trendsVOList = event.getTrendsVOList();
        if (CollUtil.isEmpty(trendsVOList)) {
            return;
        }
        assetTrendsService.assemblyTrendsData(event);
    }
    
    
}
